﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;

namespace AppTemplate.UI.Converters
{
    [ValueConversion(typeof(int), typeof(IEnumerable<int>))]
    public class NumberToArrayConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            int count = (int)value;
           return Enumerable.Range(1, count);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var arr = value as IEnumerable<int>;
            if (arr != null)
                return arr.Count();
            else return 0;
        }
    }
}
